home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include "kernel.h"
- #include "swis.h"
-
- extern void blitlines(int screenadr, int lines);
- extern unsigned intsqr(unsigned);
- extern Sin[];
-
- #define plot_pixel(x,y,color) ( ((char*)bank1) [x+320*y] = color)
- static screenbase, bank1, bank2;
- static E[54];
- /*==================================================================*/
- static void initialise(void)
- {
- int i, count=0;
- _kernel_swi_regs arm;
- int block[]={ 148, 150, -1};
- _kernel_swi(OS_WriteI + 22, &arm, &arm);
- _kernel_swi(OS_WriteI + 15, &arm, &arm); /* select mode 15 */
- _kernel_swi(OS_WriteI + 22, &arm, &arm);
- _kernel_swi(OS_WriteI + 13, &arm, &arm); /* select mode 13 */
- _kernel_swi(OS_RemoveCursors, &arm, &arm);
- arm.r[0] = (int)block;
- arm.r[1] = (int)block;
- _kernel_swi(OS_ReadVduVariables, &arm, &arm);
- screenbase = bank1 = block[0];
- bank2 = bank1 + 80*1024;
- if (block[1] < 160*1024)
- {
- fprintf(stderr, "At least 160k screen memory needed\n");
- exit(1);
- }
- for (i=400;i>=-400;i-=15)
- E[count++]=(1<<16)*1024/(1024-i);
- }
- /*==================================================================*/
- static void swap_screens(void)
- {
- int temp;
- _kernel_osbyte(19,0,0);
- _kernel_osbyte(113, bank1==screenbase ? 1 : 2, 0);
- temp = bank1;
- bank1 = bank2;
- bank2 = temp;
- }
- /*==================================================================*/
- int main(void)
- {
- int x,z,f,g,offset=0,count=0;
- initialise();
- while (!_kernel_escape_seen())
- {
- for (x=-380; x<=380; x+=15)
- {
- f=-1500, g=1500,count=0;
- for (z=380; z>=-380; z-=15)
- {
- int a,e,y;
- e=E[count++];
- a=offset+intsqr(x*x+z*z);
- y=((40*Sin[a & 255])>>16) -400;
- y=(y*e)>>16;
- if (y>=f) f=y;
- if (y<=g) g=y;
- if (y==f || y==g)
- {
- y=(25-(y>>2));
- plot_pixel( 160+((x*e)>>18), y, a>>5);
- }
- }
- }
- swap_screens();
- blitlines( bank1 + 320*90, 120);
- offset+=7;
- }
- }
- /*==================================================================*/
-